package com.example.rabbitmqextensions.listener;

import com.example.rabbitmqextensions.constant.Constants;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class DLXQueueListener {
    @RabbitListener(queues = Constants.DLX_QUEUE)
    public void Listener(Message message, Channel channel) {
        long deliverTag = message.getMessageProperties().getDeliveryTag();
        System.out.printf("%tc 死信队列接收到消息: %s, deliverTag: %d\n", new Date(), new String(message.getBody()), deliverTag);

    }
}
